package ch10.shili;

class TestWorker implements Runnable{

    @Override
    public void run() {
        Thread thread = Thread.currentThread();
        for (int i = 1; i <= 100; i++){
            System.out.println(thread.getName()+":"+ i);
        }
    }
}

public class Test1 {

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(new TestWorker());
        Thread t2 = new Thread(new TestWorker());
        Thread t3 = new Thread(new TestWorker());
        t1.setName("jack");
        t2.setName("rose");
        t3.setName("tom");
        t1.start();
        t2.start();
        t3.start();
        t1.join();
        t2.join();
        t3.join();
        System.out.println("工作完成");
    }
}
